<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>
    <button type="button" onclick="setPolicy(0)" style="position: absolute;top: 10px;right: 250px;">推荐</button>
    <button type="button" onclick="setPolicy(1)" style="position: absolute;top: 10px;right: 170px;">最短距离</button>
    <button type="button" onclick="setPolicy(3)" style="position: absolute;top: 10px;right: 90px;">避让高速</button>
    <button type="button" onclick="setPolicy(2)" style="position: absolute;top: 10px;right: 10px;">高速优先</button>

    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <script>
        var amap = null;
        var driving = null;
        map.Factory.create('mapui', {
            style: style,
            center: center,
            // center: [12500000, 2720000],
            zoom: 11,
            strategy: ['mapboxgl', 'openlayers', 'leaflet'],
            fullExtent: {
                xmin: 108.23365,
                ymin: 17.95253,
                xmax: 111.78395,
                ymax: 20.13104
            }
        }, (o) => {
            amap = o;
            map.Factory.Lbs("Driving", function (service) {
                service.init("mine", { autoview: true }, function (res) {
                    //alert("成功了");
                    console.log(res);
                });
                //更新起始点

                service.updateStart('起点', 113.30, 23.20);
                //添加途途经点
                service.addPath('途经点1', 113.35, 23.25);
                service.addPath('途经点2', 113.40, 23.30);
                //更新终点
                service.updateEnd('终点', 113.90, 23.50);
                driving = service;

            });
        });

        //切换不同的策略
        function setPolicy(policy) {
            //0推荐; 1最短距离;2高速优先 3避让高速; 
            if (driving) {
                driving.setPolicy(policy);
            }
        }
    </script>
</body>

</html>